package com.dawnling.androidutils.ui;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Point;
import android.os.Bundle;
import android.view.View;

import com.blankj.utilcode.util.ToastUtils;
import com.dawnling.androidutils.R;
import com.dawnling.androidutils.view.KTPaintAreaView;

import java.util.ArrayList;
import java.util.List;

public class KTAreaViewActivity extends AppCompatActivity {

    private KTPaintAreaView ktPaintAreaView;
    private boolean isCarPlateArea = false;
    private List<Point> roundPointsRight = new ArrayList<>();
    private List<Point> roundPointsLeft = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ktarea_view);

        ktPaintAreaView = findViewById(R.id.ktPaintAreaView);
        ktPaintAreaView.mListener = new KTPaintAreaView.PointsListener() {
            @Override
            public void pointList(Point point, List<Point> list) {
                if (isCarPlateArea) roundPointsRight.add(point);
                else roundPointsLeft.add(point);
            }

            @Override
            public void passState(boolean isExit) {
            }
        };
    }

    public void button1(View v) {
        ToastUtils.showShort("类型1");
        isCarPlateArea = false;
        ktPaintAreaView.changeRoundPoints(roundPointsLeft);
    }

    public void button2(View v) {
        ToastUtils.showShort("类型2");
        isCarPlateArea = true;
        ktPaintAreaView.changeRoundPoints(roundPointsRight);
    }
}
